//1.接口用来定义一个对象的类型
//在定义类型的时候 属性和类型都是固定的
interface obj1Type  {
    name:string,
    age:number
}

const obj1:obj1Type = {
    name:'zhang',
    age:18,
}

//2.可选属性
interface obj2Type {
    name:string,
    age:number,
    sex?:any    //可选属性
}

const obj2:obj2Type = {
    name:'zhang',
    age:68,
    sex:'lv'     //sex属性可能存在也可能不存在
}

//3.对象中有数组
type obj3ScoreType = number[]

interface obj3Type {
    name:string,
    age:number,
    score:obj3ScoreType
}

const obj3:obj3Type = {
    name:'zhang',
    age:68,
    score:[99,99,99]  
}

//4.对象中有对象
interface otherType {
    height:number,
    hobby:string[]
}

interface obj4Type {
    name:string,
    age:number,
    other:otherType
}

const obj4:obj4Type = {
    name:'wang',
    age:68,
    other:{
        height:180,
        hobby:['吸烟','喝酒','烫头']
    }
}

//只读属性
interface obj5Type {
    name:string,
    //只读属性
    readonly age:number
}

const obj5:obj5Type = {
    name:'wang',
    age:18
}

// obj5.age=0